<template>
<div class="baseFile">
    <!-- 文件模块 -->

    <div class="btns">
      <el-form size="small" inline style="text-align:right">
        <el-form-item label="文件名称">
          <el-input v-model="param.file_name"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button style="small" type="primary" icon="el-icon-search" @click="loadbaseFiles">搜索</el-button>
          <el-button type="primary" size="small" icon="el-icon-share" @click="toAddHandler">新增</el-button>
          <el-button size="small" type="primary" icon="el-icon-upload el-icon--right" @click="downloadHandler">导出</el-button>
        </el-form-item>
        </el-form>
    </div>
    
    <el-table size="small" :data="baseFile">
        <el-table-column type="index" :index="1" label="序号"></el-table-column>
        <el-table-column label="ID" prop="id" align="center"></el-table-column>
        <el-table-column label="文件名称" prop="fileName" align="center"></el-table-column>
        <el-table-column label="群组名称" prop="groupName" align="center"></el-table-column>
        <el-table-column label="下载时间" prop="uploadTime" align="center"></el-table-column>
        <el-table-column label="扩展名称" prop="extName" align="center"></el-table-column>
        <el-table-column label="文件大小" prop="fileSize" align="center"></el-table-column>
        <el-table-column label="文件类型" prop="fileType" align="center"></el-table-column>
          <el-table-column label="操作"  align="center">
      <template slot-scope="scope">
        <el-button  icon="el-icon-edit"  circle size="mini" @click="editHandler(scope.row)"></el-button>
        <el-button  icon="el-icon-delete" circle size="mini" @click="deleteHandler(scope.row)"></el-button>
      </template>
        </el-table-column>
    </el-table>
</div>
</template>

<script>
import {del, get, post} from '@/utils/request'
export default {
  // 页面数据
  data(){
    return {
      param:{},
      baseFile:[]
    }
  },
  // 页面渲染的时候会调用的函数
  created(){
    this.loadbaseFiles();
  },
  // 所有的方法
  methods:{
    downloadHandler(){
         window.location.href = "http://39.106.31.187:8888/baseFile/download"
   },
    editHandler(row){
       this.$router.push({
         path:"/file/fileCreate",
         query:row
       })
    },

    deleteHandler(row) {
      this.$confirm("此操作将永久删除该操作，是否继续？","提示",{
        confirmButtonText:"确定",
        cancelButtonText:"取消",
        type:"warning",
      }).then(()=>{
        let url="http://39.106.31.187:8888/baseFile/deleteById";
        del(url,{id:row.id}).then((resp)=>{
          this.$message({type:"success",message:resp.message});
          this.loadbaseFiles();
        });
      });
    },


    toAddHandler(){
      this.$router.push("/file/fileCreate");   //页面跳转 与后台无关
    },

    loadbaseFiles(){
      let url = "http://39.106.31.187:8888/baseFile/query";     //与后台接口相关
      get(url,this.param).then((resp)=>{
        this.baseFile = resp.data;
      });
    },
  },

created(){
  this.loadbaseFiles();
},
};
</script>


<style scoped>
.btns{
   margin-bottom: .5em;
}
 
</style>
